import { ResPage, Role, ResultData } from "@/api/interface/index";
import http from "@/api";

/**
 * @name 角色管理模块
 */
// 获取角色列表
export const getRoleList = (params: Role.ReqRoleParams) => {
  return http.post<ResPage<Role.ResRoleList>>(`/sys/role/query`, params);
};
// 获取角色详情
export const getRoleDtl = (params: { roleId: string }) => {
  return http.post<ResultData>(`/sys/role/detail`, params);
};
// 新增角色
export const addRole = (params = {}) => {
  return http.post(`/sys/role/add`, params);
};
// 编辑角色
export const editRole = (params: { roleId: string }) => {
  return http.post(`/sys/role/modify`, params);
};

// 删除角色
export const deleteRole = (params: { roleId: string }) => {
  return http.post(`/sys/role/remove`, params);
};

// 切换用户状态
export const changeRoleStatus = (params: { roleId: string; status: number }) => {
  return http.post(`/sys/role/modifyStatus`, params);
};
// 获取角色权限
export const getPermissionTree = () => {
  return http.post<Role.ResPermission>(`/sys/role/permission/selection/query`, {});
};
